package com.scnlf.scnlf.portal.core.common.nats;

import io.nats.client.Connection;
import java.util.Objects;

public class NatsConnFactory {

  private static NatsConnFactory single;

  private volatile Connection nc;

  private NatsConnFactory(){

  }

  public static Connection getSingle(NatsProperties natsProperties){
    if(Objects.isNull(single)){
      synchronized (NatsConnFactory.class){
        if(Objects.isNull(single)){
          single = new NatsConnFactory();
          single.nc = NatsConnUtil.getConn(natsProperties);
        }
      }
    }
    return single.nc;
  }

}
